//
//  DDMoneyDetailTableViewCell.m
//  DingDongZP
//
//  Created by 杨政涛 on 16/10/17.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

#import "DDMoneyDetailTableViewCell.h"

@implementation DDMoneyDetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self){
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.detailTypeLabel = [[UILabel alloc]init];
        self.detailTypeLabel.textColor = COLOR_FONT_BLACK;
//        self.detailTypeLabel.font = [UIFont systemFontOfSize:16];
        self.detailTypeLabel.adjustsFontSizeToFitWidth = YES;
        self.detailTypeLabel.text = @"";
        [self.contentView addSubview:self.detailTypeLabel];
        
        self.timeLabel = [[UILabel alloc]init];
        self.timeLabel.textColor = COLOR_FONT_LIGHT_GRAY;
        self.timeLabel.font = [UIFont systemFontOfSize:14];
        self.timeLabel.textAlignment = NSTextAlignmentRight;
        self.timeLabel.text = @"";
        [self.contentView addSubview:self.timeLabel];
        
        self.moneyLabel = [[DDCustomLabel alloc]init];
        self.moneyLabel.textColor = COLOR_FONT_BLACK;
        self.moneyLabel.font = [UIFont systemFontOfSize:14];
        self.moneyLabel.adjustsFontSizeToFitWidth = YES;
        self.moneyLabel.textAlignment = NSTextAlignmentRight;
        self.moneyLabel.text = @"";
        [self.contentView addSubview:self.moneyLabel];
        
        
        UIView *divideLine = [[UIView alloc]init];
        divideLine.backgroundColor = [UIColor colorWithWhite:0.863 alpha:1.000];
        [self.contentView addSubview:divideLine];
        
        WEAKSELF
        [divideLine mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.bottom.mas_equalTo(weakSelf.bottom).offset(-0.4);
            make.left.mas_equalTo(weakSelf);
            make.right.mas_equalTo(weakSelf);
            make.height.equalTo(@(0.5));
        }];
        
        [self.detailTypeLabel mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.top.mas_equalTo(weakSelf).offset(20);
            make.left.mas_equalTo(weakSelf).offset(25);
            make.right.mas_equalTo(weakSelf).offset(-180);
            make.height.equalTo(@(25));
        }];
        
        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.top.mas_equalTo(weakSelf).offset(15);
            make.left.mas_equalTo(weakSelf.detailTypeLabel.mas_right);
            make.right.mas_equalTo(weakSelf).offset(-20);
            make.height.equalTo(@(20));
        }];

        [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.top.mas_equalTo(self.timeLabel.mas_bottom);
            make.left.mas_equalTo(self.timeLabel);
            make.right.mas_equalTo(weakSelf).offset(-20);
            make.height.equalTo(@(25));
        }];
    }
    return self;
}


- (void)setDataModel:(DDMoneybagDetailModel *)dataModel
{
    
    if ([dataModel.type isEqualToString:@"1"]) {
        
        self.detailTypeLabel.text = @"支付宝充值";
    }else if ([dataModel.type isEqualToString:@"2"]){
       
        self.detailTypeLabel.text = @"微信充值";
    }else if ([dataModel.type isEqualToString:@"3"]){
        
        self.detailTypeLabel.text = @"个人账户消费";
    }else if ([dataModel.type isEqualToString:@"4"]){
        
        self.detailTypeLabel.text = @"共享账户消费";
    }else{
    
        self.detailTypeLabel.text = @"";
    }
    
    self.timeLabel.text = !dataModel.dt?@"":dataModel.dt;
    
    
    if ([dataModel.type isEqualToString:@"1"] || [dataModel.type isEqualToString:@"2"]) {
    
    self.moneyLabel.text = [NSString stringWithFormat:@"充值%@ 到账%@",!dataModel.real_money?@"":dataModel.real_money,!dataModel.money?@"":dataModel.money];
        /**
         *  字体颜色处理
         */
    self.moneyLabel.textColor = COLOR_FONT_LIGHT_GREEN;
    [self.moneyLabel setAttributeLabelWithtextColorPairs:@[@{@"充值":COLOR_FONT_BLACK},@{@"到账":COLOR_FONT_BLACK}]];
    self.moneyLabel.font = [UIFont systemFontOfSize:14];

    }else{
        
    self.moneyLabel.text = !dataModel.money?@"":dataModel.money;
    
        /**
         *  字体颜色处理
         */
    self.moneyLabel.textColor = COLOR_FONT_BLACK;
    self.moneyLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
    
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
